#ifndef DBMS_INCLUDED
#define DBMS_INCLUDED
#include "Table.h"
#include "index.h"

class DBMS
{
public:
    DBMS();
    virtual ~DBMS();

    void CreateTable(Create_Stmt CreateData);
    //Initialize a Table,and push  it back to the list db.
    void Insert(Insert_Stmt InsertData);
    //Type & size legality should be tested when inserting
    void Print(ofstream &Output);
    //write data to file
    void WriteToFile();
    //read data from file
    void ReadFromFile();
    //void ReadIndex();
    //Traverse db list ,and invoke print function of every table.
    void Select(Select_Stmt SelcetData);

    vector<int>*  SimpleFind(vector<void*> &data,int type,void* val,int symbol,int ma,int mi);
    vector<int>*  AndOp(vector<int>* l1,vector<int>* l2);
    vector<int>*  OrOp(vector<int>* l1,vector<int>* l2);

    void  CreateIndex();
    Chash_int* IndexFindInt(Table* table,int attr_id);
protected:

private:
    list<Table> db;
    vector<int> idf;
    vector<Chash_string*> sh;
    vector<Chash_int*> ih;
};


#endif

